/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server.domain.ai;

import Server.domain.Mob;
import Server.domain.Player;

/**
 *
 * @author Ripper
 */
public class BasicRunToMostAggrodPlayerAI extends MobAI
{
    public BasicRunToMostAggrodPlayerAI(Mob m)
    {
        super(m);
    }
    
    @Override
    public void decideWhatToDo()
    {
        int idx = -1;
        int mostAggro = -1;
        for(int a = 0; a < getAggroTowardsPlayers().size();a++)
        {
            if(getAggroTowardsPlayers().get(a) > mostAggro)
            {
                idx = a;
                mostAggro = getAggroTowardsPlayers().get(a);
            }
        }
        
        if(idx != -1)
        {
            Player p = getPlayersAwareOf().get(idx);
            
            if(p.getX() > getControlledCreature().getX())
            {
                getControlledCreature().setMovingEast(true);
                getControlledCreature().setMovingWest(false);
            }
            else if(p.getX() < getControlledCreature().getX())
            {
                getControlledCreature().setMovingEast(false);
                getControlledCreature().setMovingWest(true);
            }
            else
            {
                getControlledCreature().setMovingEast(false);
                getControlledCreature().setMovingWest(false);
            }
            
            if(p.getY() > getControlledCreature().getY())
            {
                getControlledCreature().setMovingNorth(false);
                getControlledCreature().setMovingSouth(true);
            }
            else if(p.getY() < getControlledCreature().getY())
            {
                getControlledCreature().setMovingNorth(true);
                getControlledCreature().setMovingSouth(false);
            }
            else
            {
                getControlledCreature().setMovingNorth(false);
                getControlledCreature().setMovingSouth(false);
            }
            
        }
        
        //this ai thinks only this:
        //get most aggrod target
        //if in range, attack
        //if not in range, goto closest target
        //
    }
}
